﻿//---------------------------------------------------------------------
// <copyright file="IngredientRepository.cs" company="Travis Merkel">
//      Copyright (c) Travis Merkel. All Rights Reserved.
//      Information Contained Herein is Proprietary and Confidential.
// </copyright>
// <summary>
// Class to encapsulate all Ingredient manipulation in the data store.
// </summary>
// <author>tmerkel</author>
//---------------------------------------------------------------------
namespace RecipeBook.Business.EntityFramework
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// Class to encapsulate all Ingredient manipulation in the data store.
    /// </summary>
    public class IngredientRepository : IIngredientRepository
    {
        private static RecipeDatabase DatabaseContext;

        static IngredientRepository()
        {
            DatabaseContext = new RecipeDatabase();
        }

        /// <summary>
        /// Initializes a new instance of a IngredientRepository.
        /// </summary>
        public IngredientRepository()
        {
        }

        /// <summary>
        /// Adds the given Ingredient to the data store.
        /// </summary>
        /// <param name="ingredient">Ingredient to add to the data store.</param>
        public void Add(Ingredient ingredient)
        {
            DatabaseContext.AddToIngredients(ingredient);
            DatabaseContext.SaveChanges();
        }

        /// <summary>
        /// Gets all the ingredients in the data store.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Ingredient> GetAll()
        {
            return DatabaseContext.Ingredients;
        }
    }
}
